﻿using AutoMapper;
using MediatR;
using SheepStorage.API.Application.Command.EarTagCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain;
using SheepStorage.Domain.DTO.Output;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.EarTagHandler
{
    public class EarTagSelectCommandHandler : IRequestHandler<EarTagSelectCommand, Results<Domain.DTO.Output.PageOutput<EarTagTable>>>
    {
        private readonly IEarTagService _earTagService;
        private readonly IMapper _mapper;

        public EarTagSelectCommandHandler(IEarTagService earTagService, IMapper mapper)
        {
            _earTagService = earTagService;
            _mapper = mapper;
        }
        /// <summary>
        /// 耳标列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<Domain.DTO.Output.PageOutput<EarTagTable>>> Handle(EarTagSelectCommand request, CancellationToken cancellationToken)
        {
            return Results<Domain.DTO.Output.PageOutput<EarTagTable>>.DataResult(await _earTagService.GetEarTags(request.PageIndex, request.PageSize, request.OverBit, request.BirType, request.BirthState, request.UseState));
        }


    }
}
